@extends('admin.admin')

@section('content')
        <!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
        广告管理
        <small>广告位置列表</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="/admin"><i class="fa fa-dashboard"></i> 控制面板</a></li>
        <li ><a href="/admin/ad_position">广告管理</a>></li>
        <li class="active">广告位置列表</li>
    </ol>
</section>

<!-- Main content -->
<section class="content">

    <div class="row">
        <div class="col-xs-12">
        <?php //dd("dag"); ?>
            <div class="box box-primary ">
                <div class="box-body table-responsive">
                    <a href="{{route('admin.ad_position.create')}}" class="btn btn-success"><i class="icon glyphicon glyphicon-plus"></i>添加</a>

                    {!! Form::model(@$adpos,array('route' => 'admin.ad_position.index','method' => 'get','class'=>'form-search form-inline pull-right')) !!}
                    <div class="form-group">
                        {!! Form::text('position_name',$search['position_name'],['class'=>'form-control','placeholder'=>'广告位名称'])!!}
                    </div>
                    <button type="submit" class="btn btn-primary">搜索</button>
                    <button type="button" onclick="window.location.href='/admin/ad_position'" class="btn btn-default">重置</button>
                    {!! Form::close() !!}
                </div>
            </div>
            <div class="box box-primary">
                <div class="box-header">
                    <h3 class="box-title">广告位置列表</h3>
                    <div class="box-tools">
                        <a href="{{route('admin.ad_position.create')}}" type="button" class="btn  btn-box-tool"><i class="icon  glyphicon glyphicon-plus"></i> 添加</a>
                    </div>
                </div>
                <!-- /.box-header -->
                <div class="box-body table-responsive no-padding">
                    <table class="table table-hover">
                        <tr>
                            <th>ID</th>
                            <th>广告位置名称</th>
                            <th>广告位置标识</th>
                            <th style="width: 300px;">操作</th>
                        </tr>
                        @foreach ($adpos as $ads)
                            <tr>
                                <td>{{$ads->pos_id}}</td>
                                <td>{{$ads->position_name}}</td>
                                <td>{{$ads->position_key}}</td>

                                <td>
                                    <a href="{{Route('admin.ad.show',$ads->pos_id)}}" type="button" class="btn  btn-default btn-xs"><i class="icon  glyphicon glyphicon-eye-open"></i> 查看广告列表</a>
                                    <a href="{{Route('admin.ad_position.edit',$ads->pos_id)}}" type="button" class="btn  btn-default btn-xs"><i class="icon  glyphicon glyphicon-edit"></i> 修改</a>
                                    @can('ad_delete')
                                    <button type="button" class="btn  btn-danger btn-xs"  data-toggle="modal" data-target="#modal{{$ads->pos_id}}"><i class="icon  glyphicon glyphicon-remove"></i> 删除</button>

                                    <div id="modal{{$ads->pos_id}}" class="modal fade">
                                        <div class="modal-dialog">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                                    <h4 class="modal-title">删除警告:</h4>
                                                </div>
                                                <div class="modal-body">
                                                    <p>确认要删除[{{$ads->position_name}}]吗?</p>
                                                </div>
                                                <div class="modal-footer">


                                                    {!! Form::open(['route' => ['admin.ad_position.destroy', $ads->pos_id],'name'=>$ads->pos_id]) !!}
                                                    {!! Form::hidden('_method', 'DELETE') !!}
                                                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                                    <button type="submit" class="btn btn-danger">删除</button>

                                                    {!!Form::close()   !!}
                                                </div>
                                            </div><!-- /.modal-content -->
                                        </div><!-- /.modal-dialog -->
                                    </div><!-- /.modal -->
                                    @endcan
                                </td>

                            </tr>
                        @endforeach
                    </table>
                </div>
                <!-- /.box-body -->
            </div>
            <!-- /.box -->
            {!! $adpos->render() !!}

        </div>
    </div>



</section>
<!-- /.content -->

<script>
    $('.btn-danger').on('click',function(){
        console.log('11');
    });
</script>
@endsection